﻿using System;
using System.Windows.Input;
using MyFloridaHouse.libSvBingMapsMultiShape;

namespace MyFloridaHouse.libSvOpenDistricts.MapShapes
{
    public delegate void RegionMouseEnterEventHandler(object sender, EventArgs e);
    public delegate void RegionMouseLeaveEventHander(object sender, EventArgs e);
    public delegate void RegionMouseLeftButtonUpEventHandler(object sender, MouseButtonEventArgs e);

    public partial class Region
    {
        public static event RegionMouseEnterEventHandler RegionMouseEnter;
        public static event RegionMouseLeaveEventHander RegionMouseLeave;
        public static event RegionMouseLeftButtonUpEventHandler RegionMouseLeftButtonUp;

        public static void RegionShapeMouseEnterHandler(object sender, MouseEventArgs args)
        {
            MapMultiShapeBase currentShape = ((MapMultiShapeBase)sender);
            Region region = (Region)currentShape.Tag;
            region.Select();

            // re-fire the event so outsiders can know about it
            RegionMouseEnter(region, args);

        }

        public static void AddShapeEventHandlers(MapMultiShapeBase baseShape)
        {
            baseShape.MouseEnter += new MouseEventHandler(Region.RegionShapeMouseEnterHandler);
            baseShape.MouseLeave += new MouseEventHandler(Region.RegionShapeMouseLeaveHandler);
            baseShape.MouseLeftButtonUp += new MouseButtonEventHandler(Region.RegionShapeMouseLeftButtonUpHandler);
        }


        public static void RegionShapeMouseLeaveHandler(object sender, MouseEventArgs args)
        {
            MapMultiShapeBase currentShape = ((MapMultiShapeBase)sender);
            Region region = (Region)currentShape.Tag;
            region.Unselect();


            // re-fire the event so outsiders can know about it
            RegionMouseLeave(region, args);
        }

        public static void RegionShapeMouseLeftButtonUpHandler(object sender, MouseButtonEventArgs args)
        {
            MapMultiShapeBase currentShape = ((MapMultiShapeBase)sender);
            Region region = (Region)currentShape.Tag;


            // re-fire the event so outsiders can know about it
            RegionMouseLeftButtonUp(region,args);
        }
    }
}
